#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

int minNumberInRotateArray(int* nums, int numsLen)
{
    // write code here
    int minval = *nums;
    int left = 1;
    int right = numsLen - 1;
    int mid = 0;

    while (left <= right)
    {
        mid = (right + left) / 2;

        if (minval <= *(nums + mid))
        {
            left = mid + 1;
        }
        else
        {
            minval = *(nums + mid);
            right = mid - 1;
        }
    }

    return minval;
}

int main()
{
    int nums[5] = { 3,4,5,1,2 };
    int numsLen = sizeof(nums) / sizeof(nums[0]);
    int ret = 0;

    ret = minNumberInRotateArray(nums, numsLen);

    printf("%d", ret);

    return 0;
}